package com.gcxy.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gcxy.conf.result.R;
import com.gcxy.dto.FenceDto;
import com.gcxy.entity.Fence;
import com.gcxy.service.FenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiang
 * @since 2023-12-12
 */
@Api(tags = "围栏管理")
@RestController
@RequestMapping("/fence")
public class FenceController {

    @Autowired
    private FenceService fenceService;

    @ApiOperation("新增围栏接口")
    @PostMapping("/addFence")
    public R addFence(@Validated @RequestBody Fence fence){
        return fenceService.addFence(fence);
    }

    @ApiOperation("分页查询围栏接口")
    @PostMapping("/getFenceByPage")
    public R<Page<FenceDto>> getFenceByPage(@RequestBody FenceDto fenceDto){
        return fenceService.getFenceByPage(fenceDto);
    }

    @ApiOperation("修改围栏接口")
    @PostMapping("/updateFence")
    public R updateFence(@RequestBody Fence fence){
        return fenceService.updateFence(fence);
    }

    @ApiOperation("停用围栏接口")
    @PostMapping("/updateIsEnable")
    public R updateIsEnable(@RequestBody Fence fence){
        return fenceService.updateIsEnable(fence);
    }
}

